using System.Linq.Expressions;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using SecondDemo.API.Filters;
using SecondDemo.API.Models;

namespace SecondDemo.API.Controllers;
[EnableCors("any")]
[ApiController]
[Route("api/[controller]/[action]")]
public class WeatherForecastController : ControllerBase
{
    [HttpGet("get-name")]
    public string Get()
    {
        string str = "Hello Orion";
        return str;
    }
    // 这里的 i 要一致
    [HttpGet("{i}")]
    public string Get1(int i)
    {
        string str = "this is the i :" + i;
        return str;
    }
    // 返回值类型
    [HttpGet]
    [CustomActionFilter]
    [CustomAuthorizationFilter]
    public ActionResult<TestPostViewModel> GetIActionResult()
    {
        return Ok(new TestPostViewModel{I=20,Name="Orion"});
    }
    [HttpPost]
    public string Post(TestPostViewModel postModel)
    {
        string str = postModel.Name + "has logined " + postModel.I + "times";
        return str;
    }
    // 数据更新接口
    [HttpPut]
    public string DemoPut(int id,TestPostEditViewModel postModel)
    {
        string str = string.Empty;
        return str;
    }
    // 数据删除接口
    [HttpDelete]
    public string DemoDelete()
    {
        string str = string.Empty;
        return str;
    }
}
